//--------------------------------------------------------------------------------
// Alec G Thilenius
//
// This software is distributed under the MIT License, available at the following
// URL:
// http://www.opensource.org/licenses/mit-license.php
//--------------------------------------------------------------------------------

#pragma once

#include "PCH.h"
#include "Vertex.h"

namespace AlecThilenius
{
	class Graph
	{
	public:

		Graph(void);
		~Graph(void);

		//-------------------   Generic    ---------------------
		virtual void Clear();

		//-------------------    Vertex     ---------------------
		VertexPtr AddVertex	( const std::string& vertexName );
		VertexPtr GetVertex	( const std::string& vertexName );
		bool RemoveVertex	( const std::string& vertexName );
		int VerticieCount	() const;

		//-------------------   Edge       ---------------------
		EdgePtr AddEdge		( const std::string& fromVertexName, const std::string& toVertexName, double weight );
		EdgePtr GetEdge		( const std::string& fromVertexName, const std::string& toVertexName );
		bool RemoveEdge		( const std::string& fromVertexName, const std::string& toVertexName );
		int EdgeCount		() const;

		//-------------------   Streaming  ---------------------
		void Print			( std::ostream& oS );
		bool Load			( std::istream& iS );

		//-------------------   EndRefs    ---------------------
		VertexPtr			NullVertex;
		EdgePtr				NullEdge;

	private:
		//-------------------   Typedef    ---------------------
		typedef std::unordered_map<std::string, VertexPtr> VertMap;
		typedef VertMap::iterator VertMapIttr;

		//-------------------   Member     ---------------------
		VertMap m_verts;

		int m_vertexCount;
		int m_edgeCount;

		//-------------------   Friends    ---------------------
		friend Vertex;
	};
};

//-------------------    Streaming Forward Declarations ---------------------
std::ostream& operator << ( std::ostream& stream, AlecThilenius::Graph& graph );
std::istream& operator >> ( std::istream& stream, AlecThilenius::Graph& graph );

